package com.gxa.employment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.employment.entity.dto.PageBean;
import com.gxa.employment.entity.pojo.Enterprise;
import com.gxa.employment.mapper.EnterpriseMapper;
import com.gxa.employment.service.EnterpriseService;

import org.springframework.stereotype.Service;


import java.util.List;


/**
 * <p>
 * 企业信息表 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-03-25
 */
@Service
public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper, Enterprise> implements EnterpriseService {

    @Override
    public List<Enterprise> listByKeyword(String keyword) {
        QueryWrapper<Enterprise> wrapper = new QueryWrapper<>();
        wrapper.like("ent_name", keyword)
                .or()
                .like("ent_addr", keyword)
                .or()
                .like("ent_contact", keyword);

        return baseMapper.selectList(wrapper);
    }
    @Override
    public Page<Enterprise> getEnterprisePage(PageBean pageBean) {
        Page<Enterprise> page = new Page<>(pageBean.getPage(), pageBean.getSize());
        QueryWrapper<Enterprise> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("ent_id");  // 替换 last()
        return baseMapper.selectPage(page, queryWrapper);
    }
}

